////
//// Source code recreated from a .class file by IntelliJ IDEA
//// (powered by FernFlower decompiler)
////
//
//package com.demo;
//
//import java.sql.ResultSet;
//import java.util.Scanner;
//
//public class Main {
//    public static final String DBURL = "jdbc:oracle:thin:@172.16.249.201:1521:crq";
//    public static final String DBUSER = "gynscrq2";
//    public static final String DBPSW = "gynscrq2";
//    public static final String REMOTE_IP = "172.31.231.46";
//    public static final int REMOTE_PORT = 22;
//    public static final String REMOTE_USER = "weblogic";
//    public static final String REMOTE_PASSWD = "weblogic";
//    public static final String REMOTE_REPORT_FOLDER = "/app/weblogic/CRQ/PBCReportHtml/ICR/";
//    public static final String TEMPLATE_SUCCESS_PATH = "template/success.json";
//    public static final String CREATE_FOLDER_PATH = "%s/ICR%s/";
//    public static final String DEFAULT_SERIALNO = "00000200";
//
//    public Main() {
//    }
//
//    public static void main(String[] args) throws Exception {
//        Scanner scanner = new Scanner(System.in);
//        System.out.println("请输入 [身份证号]:");
//        String certNo = scanner.nextLine();
//        System.out.println("请输入 [姓名],只更新可省略:");
//        String name = scanner.nextLine();
//        System.out.println("[姓名]: = "+name);
//        if (name == null) {
//            name = "";
//        }
//
//        String templatePath = FileHandler.getFileFullPath("template/success.json");
//        ConnectDB db = new ConnectDB("jdbc:oracle:thin:@172.16.249.201:1521:crq", "gynscrq2", "gynscrq2");
//        String sql_check = SqlDefine.getSqlCheck(certNo);
//        ResultSet resultSet = db.sql().select(sql_check);
//        resultSet.next();
//        int count = resultSet.getInt(1);
//        String dateStr = NumberGenerator.getDateStr();
//        String relativeFolderPath = String.format("%s/ICR%s/", dateStr, NumberGenerator.getNowStr());
//        String remoteFolderPath = "/app/weblogic/CRQ/PBCReportHtml/ICR/" + relativeFolderPath;
//        Remote.createFolder("172.31.231.46", 22, "weblogic", "weblogic", remoteFolderPath);
//        String sql_query;
//        String serialNo;
//        String tempSerial;
//        String newSerialNo;
//        String timeStr;
//        String sql_insert;
//        if (count == 0) {
//            System.out.println("指定身份证征信数据不存在，开始创建...");
//            sql_query = SqlDefine.getSqlMaxSerial(dateStr);
//            resultSet = db.sql().select(sql_query);
//            serialNo = dateStr + "00000200";
//            if (resultSet != null) {
//                resultSet.next();
//                tempSerial = resultSet.getString(1);
//                if (tempSerial != null && !"".equals(tempSerial)) {
//                    serialNo = tempSerial;
//                }
//            }
//
//            long serialInt = Long.parseLong(serialNo);
//            newSerialNo = String.valueOf(++serialInt);
//            timeStr = NumberGenerator.getTimeStr("yyyy/MM/dd HH:mm:ss:SSS");
//            sql_insert = SqlDefine.getSqlInsert(newSerialNo, certNo, name, timeStr, relativeFolderPath);
//            db.sql().excute(sql_insert);
//            System.out.println("数据创建成功");
//        }
//
//        sql_query = SqlDefine.getSqlQuery(certNo);
//        resultSet = db.sql().select(sql_query);
//        resultSet.next();
//        serialNo = resultSet.getString(1);
//        System.out.println("开始创建json...");
//        tempSerial = NumberGenerator.createReportNo();
//        String newJsonPath = NumberGenerator.createReportPathCustom(relativeFolderPath);
//        newSerialNo = createJson(templatePath, newJsonPath, tempSerial, certNo, name);
//        System.out.println("创建成功..." + newSerialNo);
//        timeStr = "/app/weblogic/CRQ/PBCReportHtml/ICR/" + newJsonPath;
//        Remote.scpFile("172.31.231.46", 22, "weblogic", "weblogic", newSerialNo, timeStr);
//        System.out.println("开始数据更新...");
//        sql_insert = SqlDefine.getSqlUpdate(tempSerial, newJsonPath, name, serialNo);
//        int ok = db.sql().update(sql_insert);
//        if (ok == 0) {
//            System.out.println("数据更新失败.");
//        } else {
//            System.out.println("数据更新成功.");
//        }
//
//        db.close();
//    }
//
//    public static String createJson(String templatePath, String newJsonPath, String reportNo, String certNo, String name) {
//        String content = FileHandler.getFileContent(templatePath);
//        String newContent = FileHandler.replaceContent(content, "REPORTNO", reportNo);
//        newContent = FileHandler.replaceContent(newContent, "CERTNO", certNo);
//        if (name != null && !"".equals(name)) {
//            newContent = FileHandler.replaceContent(newContent, "NAME", name);
//        }
//
//        String folderPath = FileHandler.getFolderPath(templatePath);
//        String fileName = FileHandler.getFileName(newJsonPath);
//        String filepath = folderPath + "generator/" + fileName;
//        FileHandler.save(filepath, newContent);
//        return filepath;
//    }
//}
